<template>
  <div class="user-container">
    <h2>User</h2>
    <ul class="user">
      <li 
        v-for="user in users" 
        :key="user.id"
      >
        <nuxt-link 
          :to="'/costom/user/'+user.id"
        >{{ user.name }}</nuxt-link>
      </li>
    </ul>
    <br>
    <nuxt-link 
      to="/"
      class="nuxt_link" 
    >返回首页</nuxt-link>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  mounted() {
    document.title = 'ssr-fy-list'
  },
  async asyncData() {
    const { data } = await axios.get(
      'https://jsonplaceholder.typicode.com/users'
    )
    return {
      users: data
    }
  }
}
</script>
<style scoped>
@import '~/assets/style/common.less';
ul,
li {
  list-style: none;
  line-height: 2;
}
.user-container {
  text-align: center;
  margin-top: 100px;
  font-family: sans-serif;
}
.users {
  list-style-type: none;
}
.users li a {
  display: inline-block;
  width: 200px;
  border: 1px #ddd solid;
  padding: 10px;
  text-align: left;
  color: #222;
  text-decoration: none;
}
.users li a:hover {
  color: orange;
}
</style>
